package com.hcss.sys.modulelog.controller;

import com.github.pagehelper.PageInfo;
import com.hcss.sys.modulelog.model.HcSysModulelog;
import com.hcss.sys.modulelog.model.par.HcSysModulelogPar;
import com.hcss.sys.modulelog.service.HcSysModulelogService;
import com.hcss.util.AjaxResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * @描述: HcSysModulelog 功能模块
 * @作者: fengzhaodong
 * @创建日期: 2019-09-30 17:08:47
 */
@Slf4j
@RestController
@RequestMapping("hcSysModulelog")
public class HcSysModulelogController {

	@Autowired
    private HcSysModulelogService hcSysModulelogService;




	/**
	 * HcSysModulelog数据列表页面
     *
	 * @return
	 */
	@GetMapping("listPage")
	public ModelAndView listPage(){
		return new ModelAndView("/sys/modulelog/hcSysModulelog-listPage");
	}
	

	
	/**
     * HcSysModulelog分页数据接口
     *
     * @param par 带有查询参数的对象
     * @return
     */
	@RequestMapping("/list")
	public AjaxResult hcSysModulelog(HcSysModulelogPar par){

        try {

        	if (par.getPagenation()) {
        		PageInfo<HcSysModulelog> list = hcSysModulelogService.queryPagingData(par);
                return AjaxResult.getPageHelperTableResult(list);
        	} else {
        		List<HcSysModulelog> list =  hcSysModulelogService.queryAllData(par);
        		return AjaxResult.getSuccessResult(list);
        	}
        } catch (Exception e) {
            log.error("数据查询出错，参数：" + par.toString(), e);
            return AjaxResult.getErrorResult(e.getMessage());
        }
	}
	
	/**
     * HcSysModulelog 单个数据的获取
     * @param id HcSysModulelog主键
     * @return
     */
	@GetMapping("/{id}")
	public AjaxResult getHcSysModulelogById(@PathVariable("id") String id){
        HcSysModulelog hcSysModulelog = hcSysModulelogService.selectByPK(id);
        return new AjaxResult(hcSysModulelog);
	}
	

	

	
}